﻿using System;
using System.Collections.Generic;
using System.Text;

using HyEduOnline.Entities;
using HyEduOnline.Data;
namespace HyEduOnline.Server.Student
{
	/// <summary>
	///		此用于处理表对象 'tb_StuPracticeList' 
	/// </summary>
	/// <remarks>
	/// 	此结构由代码由TMS使用代码生成器书写生成，请不要直接修改.
	///注意:此代码可能和同名的视图生成一个完整对象
	/// </remarks>
	

	
	public partial class StuPracticeListBaseDAO
	{
		
	#region 表生成代码
		protected int TotalCount = -1;
		
		
		/// <summary>
       
		
		/// <summary>
        /// 取所有的对象,例如TList<???>
        /// </summary>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, true)]
        public  TList<TbStuPracticeList> GetAll()
        {
            return DataRepository.Provider.TbStuPracticeListProvider.GetAll();
        }

		/// <summary>
        /// 通过id来取对象
        /// </summary>
        /// <param name="id">对象的ID</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public TbStuPracticeList GetByID(int id)
        {
            return DataRepository.Provider.TbStuPracticeListProvider.GetById(id);
        }

        /// <summary>
        /// 条件查询分页
        /// </summary>
        /// <param name="whereClause">条件</param>
        /// <param name="startRowIndex">起始值</param>
        /// <param name="maximumRows">每页的最大值</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public  TList<TbStuPracticeList> GetByPage(string whereClause, int startRowIndex, int maximumRows)
        {

            return DataRepository.Provider.TbStuPracticeListProvider.GetPaged(whereClause, "ID", (int)startRowIndex / maximumRows, maximumRows, out TotalCount);

        }
		
		 /// <summary>
        ///支持Ext的分页查询,表
        /// </summary>
        /// <param name="whereClause">查询条件</param>
        /// <param name="start">起始位置</param>
        /// <param name="limit">最大条数</param>
        /// <param name="sort">排序列</param>
        /// <param name="dir">排序方向("DESC","ASC")</param>
        /// <param name="count">取得记录数</param>
        /// <returns>TList<???></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public  TList<TbStuPracticeList>  GetByPage(string whereClause, int start, int limit, string sort, string dir, out int count)
        {
            string sOrder = "";
            if (! String.IsNullOrEmpty(sort ) && sort.ToUpper() != "ID")
            {
                sOrder = sort.Insert(1, "_") + " " + dir;
            }
            else
            {
                 if (sort != null && sort.ToLower() == "id") sOrder = sort + " " + dir;
            }
			
            return DataRepository.Provider.TbStuPracticeListProvider.GetPaged(whereClause, sOrder, (int)start / limit, limit, out count);
        }
		
		
		
        /// <summary>
        /// 分页查询计数
        /// </summary>
        /// <param name="whereClause">查询调价</param>
		/// <param name="startRowIndex">起始值</param>
        /// <param name="maximumRows">每页的最大值</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, false)]
        public int GetCount(string whereClause, int startRowIndex, int maximumRows)
        {
            if (TotalCount != -1)
            {
                return TotalCount;
            }
            else
            {
                DataRepository.Provider.TbStuPracticeListProvider.GetTotalItems(whereClause, out TotalCount);
                return TotalCount;
            }
        }
		
		
		
		
		/// <summary>
        /// 更新对象，传入的是一个对象
        /// </summary>
        /// <param name="item">需要更新的对象</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, true)]
        public bool Update(TbStuPracticeList item)
        {
            return DataRepository.Provider.TbStuPracticeListProvider.Update(item);
        }
		
		/// <summary>
        /// 更新对象，传入的是一个Tlist对象
        /// </summary>
        /// <param name="items">需要更新的TList对象</param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, false)]
        public int Update(TList<TbStuPracticeList> items)
        {
            return DataRepository.Provider.TbStuPracticeListProvider.Update(items);
        }
		
		
		
		/// <summary>
        /// 更新对象，传入的是此对象的多个属性，属性个数为  11
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Update, false)]
        public bool Update(
		System.String SPracticeName, System.Int32? ICourseId, 
			System.String SCouseCode, System.Int32? ITeaId, System.String STeaCode, 
			System.Int32? ITermId, System.String STermName, System.DateTime? DCreateTime, 
			System.Int32? ITotal, System.String STeaName, System.String SCatalog, 
			System.Int32 Id
		)
        {
			
			TbStuPracticeList item =new TbStuPracticeList();
			
			
			

			item.SPracticeName = SPracticeName;
			item.ICourseId = ICourseId;
			item.SCouseCode = SCouseCode;
			item.ITeaId = ITeaId;
			item.STeaCode = STeaCode;
			item.ITermId = ITermId;
			item.STermName = STermName;
			item.DCreateTime = DCreateTime;
			item.ITotal = ITotal;
			item.STeaName = STeaName;
			item.SCatalog = SCatalog;
			
			
			item.Id = Id;
			
            return DataRepository.Provider.TbStuPracticeListProvider.Update(item);
        }
		
		
		/// <summary>
        /// 通过ID来删除对象
        /// </summary>
        /// <param name="id">对象ID</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, true)]
        public int Del(string ids)
        {
		
			TList<TbStuPracticeList> tmpList= GetByPage("id in ("+ids+")",0,int.MaxValue);
			

            return Del(tmpList);

        }
		
		
		/// <summary>
        /// 通过ID来删除对象
        /// </summary>
        /// <param name="id">对象ID</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, true)]
        public bool Del(int id)
        {

            return DataRepository.Provider.TbStuPracticeListProvider.Delete(id);

        }
		
		/// <summary>
        /// 通过对象删除记录
        /// </summary>
        /// <param name="item">对象</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, false)]
        public bool Del(TbStuPracticeList item)
        {

            return DataRepository.Provider.TbStuPracticeListProvider.Delete(item);

        }
		
		/// <summary>
        /// 通过对象删除记录
        /// </summary>
        /// <param name="items">需删除的TList对象</param>
        /// <returns></returns>
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Delete, false)]
        public int Del(TList<TbStuPracticeList> items)
        {

            return DataRepository.Provider.TbStuPracticeListProvider.Delete(items);

        }
		
		
		/// <summary>
        /// 插入一个对象
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
		 [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public bool Insert(TbStuPracticeList item)
        {
            return DataRepository.Provider.TbStuPracticeListProvider.Insert(item);
        }
		
		/// <summary>
        /// 插入一个TList对象
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
		 [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Insert, false)]
        public int Insert(TList<TbStuPracticeList> items)
        {
            return DataRepository.Provider.TbStuPracticeListProvider.Insert(items);
        }
        
		/// <summary>
        /// 更具条件查找
        /// </summary>
        /// <param name="whereClause">需要查找的条件</param>
        /// <returns>TList对象</returns>
        public TList<TbStuPracticeList> GetByCondition(string whereClause)
        {
            return DataRepository.Provider.TbStuPracticeListProvider.Find(whereClause);
        }
		
		


#endregion 表生成代码

#region 兼容代码



		 /// <summary>
        ///兼容查询
        /// </summary>
        /// <param name="whereClause">查询条件</param>
        /// <param name="start">起始位置</param>
        /// <param name="limit">最大条数</param>
        /// <param name="sort">排序列</param>
        /// <param name="dir">排序方向("DESC","ASC")</param>
        /// <param name="count">取得记录数</param>
        /// <returns>TList<???></returns>
		
        public  TList<TbStuPracticeList>  getByPageDataBase( int start, int limit, string sort,string whereClause, out int count)
        {
		///(0, 10000, "I_Level ASC,I_Group ASC,ID ASC", "I_Type=1 and id<>1", out count);
            string sOrder = "";
            string[] sortTmps=sort.Split(' ');

            if (!String.IsNullOrEmpty(sort) && sortTmps[0].ToUpper() != "ID")
            {

                sOrder = sort.Insert(1, "_") ;
            }
            else
            {
                 if (sort != null && sort.ToLower() == "id") sOrder = sort + " " ;
            }
			
            return DataRepository.Provider.TbStuPracticeListProvider.GetPaged(whereClause, sOrder, start , limit, out count);
        }


 /// 取所有的对象,例如TList<???>
        /// </summary>
        /// <returns></returns>
		[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select, true)]
        public  TList<TbStuPracticeList> findAll()
        {
            return DataRepository.Provider.TbStuPracticeListProvider.GetAll();
        }
		

		 public  TList<TbStuPracticeList> findByProperty(String propertyName, Object value)
        {
            TList<TbStuPracticeList> tmpList = new TList<TbStuPracticeList>();
            try
            {

                string whereC = "";
				 string FirC=propertyName.Substring(0,1);
                if (FirC != "I" || FirC != "F")
                {
                
                    value="'"+value.ToString()+"'";
                }
				
                if (!String.IsNullOrEmpty(propertyName) && propertyName.ToUpper() != "ID")
                {
                    whereC = propertyName.Insert(1, "_") + "= " + value.ToString();
                }
                else
                {
                    whereC = propertyName + "= " + value.ToString();
                }

              
                tmpList = GetByPage(whereC,0,int.MaxValue);
                return tmpList;
            }
            catch (Exception re)
            {
                throw re;
            }
        }//end for findByProperty
		
		
		
		  /*
       *get the Object through SPracticeName
       */
	public IList<TbStuPracticeList> findBySPracticeName(Object _SPracticeName)
        {
            return findByProperty("SPracticeName",_SPracticeName);
         }
		
		
		  /*
       *get the Object through ICourseId
       */
	public IList<TbStuPracticeList> findByICourseId(Object _ICourseId)
        {
            return findByProperty("ICourseId",_ICourseId);
         }
		
		
		  /*
       *get the Object through SCouseCode
       */
	public IList<TbStuPracticeList> findBySCouseCode(Object _SCouseCode)
        {
            return findByProperty("SCouseCode",_SCouseCode);
         }
		
		
		  /*
       *get the Object through ITeaId
       */
	public IList<TbStuPracticeList> findByITeaId(Object _ITeaId)
        {
            return findByProperty("ITeaId",_ITeaId);
         }
		
		
		  /*
       *get the Object through STeaCode
       */
	public IList<TbStuPracticeList> findBySTeaCode(Object _STeaCode)
        {
            return findByProperty("STeaCode",_STeaCode);
         }
		
		
		  /*
       *get the Object through ITermId
       */
	public IList<TbStuPracticeList> findByITermId(Object _ITermId)
        {
            return findByProperty("ITermId",_ITermId);
         }
		
		
		  /*
       *get the Object through STermName
       */
	public IList<TbStuPracticeList> findBySTermName(Object _STermName)
        {
            return findByProperty("STermName",_STermName);
         }
		
		
		  /*
       *get the Object through DCreateTime
       */
	public IList<TbStuPracticeList> findByDCreateTime(Object _DCreateTime)
        {
            return findByProperty("DCreateTime",_DCreateTime);
         }
		
		
		  /*
       *get the Object through ITotal
       */
	public IList<TbStuPracticeList> findByITotal(Object _ITotal)
        {
            return findByProperty("ITotal",_ITotal);
         }
		
		
		  /*
       *get the Object through STeaName
       */
	public IList<TbStuPracticeList> findBySTeaName(Object _STeaName)
        {
            return findByProperty("STeaName",_STeaName);
         }
		
		
		  /*
       *get the Object through SCatalog
       */
	public IList<TbStuPracticeList> findBySCatalog(Object _SCatalog)
        {
            return findByProperty("SCatalog",_SCatalog);
         }
		
		
#endregion 兼容代码
#region 自定义代码


		
#endregion 自定义代码

	}
}